<!--
 * @Author: your name
 * @Date: 2020-11-16 11:56:06
 * @LastEditTime: 2020-11-16 16:25:45
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \H5 2010 studyd:\H5 2010 练习\第二阶段\DAY 16\创建对象.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 1、字面量
        // const obj1 = {}
        // const obj2 = {}

        // obj1.name = '张三'
        // obj1.age = 38
        // obj2.name = '李四'
        // obj2.age = 28

    
    // 2、内置构造函数
        // const obj1 = new Object()
        // const obj2 = new Object()

        // obj1.name = '张三'
        // obj1.age = 38
        // obj2.name = '李四'
        // obj2.age = 28


    // 3、工厂函数
        // function person(name,age,hobby){
        //     const obj = {}
        //     obj.name = name
        //     obj.age = age
        //     obj.hobby = hobby
        //     return obj
        // }

        // const obj1 = person('桐生一马',34,'堂岛之龙')
        // const obj2 = person('真岛吾朗',38,'嶋野狂犬')

    //4、构造函数
        function Person(name,age,hobby){
            // this => 实例对象
            this.name = name 
            this.age = age
            this.hobby = hobby
        }

        const obj1 = new Person('桐生一马',34,'堂岛之龙')
        const obj2 = new Person('真岛吾朗',38,'嶋野狂犬')

    console.log(obj1)
    console.log(obj2)
</script>
</html>